package game.view.panel.load
{
	import com.base.type.LayerEnum;
	import com.greensock.TweenMax;
	import com.net.SocketManage;
	
	import flash.events.*;
	import game.view.panel.game.GamePanel;
	import game.GlobalConfig;
	import game.controller.mediator.LoadMediator;
	import game.view.base.loadpanel.LoadPanelUI;
	
	import morn.core.handlers.Handler;
	import morn.core.managers.ResLoader;
	public class LoadPanel extends LoadPanelUI
	{
		private var icoooo:Boolean=false;
		public function LoadPanel()
		{
			super();
			setLayerType(LayerEnum.LAYER_PANEL);
			setMediatorClass(LoadMediator);
		}
		
		override protected function initialize():void
		{
			//var __y:Number=(icoooo?238:180);
			//TweenMax.to(loadIco,1,{y:__y,onComplete:loadIcocomPlete,onCompleteParams:[]});
		}
		
		override protected function reset():void
		{
			super.reset();
		
		}
		
		override public function showHandler():void
		{
			super.showHandler();
			//
			trace("[LoadPanel showHandler]");
			startLoad();
		}
		/**
		 * 开始游戏
		 */
		private function startGame():void
		{

			ZooMain.view.closeView(LoadPanel);
			ZooMain.view.showView(GamePanel);
			SocketManage.instance.init(GlobalConfig.webIp);
		}
		
		override protected function updateData(viewData:Object):void
		{
			
		}
		private function loadIcocomPlete():void{
			icoooo=!icoooo;
			//var __y:Number=(icoooo?238:180);
			//TweenMax.to(loadIco,1,{y:__y,onComplete:loadIcocomPlete,onCompleteParams:[]});
		}
		//
		private function startLoad():void
		{
			setProgress(0);
			var arr:Array = [];		
			arr.push({url: "assets/img.swf?v="+GlobalConfig.version, type: ResLoader.SWF, size: 500});
			arr.push({url: "assets/aaaa.swf?v="+GlobalConfig.version, type: ResLoader.SWF, size: 500});
		
			ZooMain.loader.loadAssetUrlList(arr, new Handler(onComplete),new Handler(onProgress));
		}
		
		private function onComplete():void
		{
			startGame();
		}
		
		private function onProgress(value:int):void
		{
			setProgress(value*0.01);
		}
		
		private function setProgress(value:Number):void
		{
			value = value<0?0:value;
		}
		override protected function dispose():void{
			super.dispose();
			//TweenMax.killTweensOf(loadIco);
			trace("LoadPanel dispose");
		}
		/*override protected function onRemovedFromStage(e:Event):void{
			super.dispose();
			trace("LoadPanel onRemovedFromStage",this.parent);
		}*/
	}
}